package net.xxcl.stuManager.mapper;

import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class DBSessionFactory {
	
	private static SqlSessionFactory sqlSessionFactory = null;
	
	public static SqlSessionFactory getSqlSessionFactory() {
		if(sqlSessionFactory==null){
			try {
				Reader reader = Resources.getResourceAsReader("MyBatisConfiguration.xml");
				sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
			} catch (IOException e) {
				System.out.println("Mybatis配置文件出错！");
			}
		}
		return sqlSessionFactory;
	}
}
